package day13.practice;

/**
 * @Author juzipi
 * @Date 2021/6/29 10:48
 * @Info
 */
public class InstanceTest {

    public static void main(String[] args) {
        InstanceTest instanceTest = new InstanceTest();
        instanceTest.method(new Teacher());
    }

    public void method(Person person){
        String info = person.getInfo();
        System.out.println(info);
//        if (person instanceof Teacher){
//            System.out.println("teacher student");
//            System.out.println("studnet");
//            System.out.println("person");
//        }else if (person instanceof Student){
//            System.out.println("studnet");
//            System.out.println("person");
//        }else {
//            System.out.println("person");
//        }

        if (person instanceof Teacher){
            System.out.println("teacher student");
        }
        if (person instanceof Student){
            System.out.println("Student");
        }
        if (person instanceof Person){
            System.out.println("person");
        }

    }

}

class Person{
    protected String name = "person";

    protected int age = 20;

    public String getInfo(){
        return name + age;
    }
}
class Student extends Person{
    protected String school = "sgg";

    @Override
    public String getInfo() {
        return super.getInfo() + school;
    }
}

class Teacher extends Student{

    protected String major = "软件";

    @Override
    public String getInfo() {
        return super.getInfo()+major;
    }
}
